<?php
$this->headTitle($this->translator('enterprise_search_advanced_page_title'));
$this->headLink()
    ->appendStylesheet($this->APP_STATIC_SERVER . '/js/jquery.ui/themes/base/ui.all.css')
    ->appendStylesheet($this->APP_STATIC_SERVER . '/js/jquery.ui/themes/base/ui.datepicker.css');

$this->headScript()
    ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.validate/jquery.validate.min.js')
    ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.ui/ui.datepicker.js');
?>
<style>
    .col_50l{
        float:left;
        width:48%;
    }
    .col_50r{
        float:right;
        width:48%;
    }
    .subrow{
        padding-bottom:10px;
        display:table;
        width:100%;
    }
    .col_70l{
        float:left;
        width:69.2%;
    }
    .col_30r{
        float:right;
        width:30%;
    }
    .col_30l{
        float:left;
        width:29%;
    }
    .col_70r{
        float:right;
        width:70%;
    }
    .webwidget_vertical_menu li{
        margin-left:0px;
    }
    .caption_box{
        margin-bottom:5px; background:#EFEDED none repeat;
    }
    .caption_box span{
        padding:8px;
        text-transform:uppercase;
    }
    .box_33l{
        float:left;
        width:33.3%;
        background:#EFEDED none repeat;
    }
    .subbox_33l{
        background:#FFFFFF;
        margin:5px 0px 10px 5px;
        padding:5px
    }

    .col_70l .t_bizprofile_register label{
        line-height: 23px;
    }
</style>
<?php
    $skin_url = $this->APP_STATIC_SERVER . '/skins/'. $this->APP_TEMPLATE . '/'. $this->APP_SKIN;
?>
<div class="grid_12 pb10">
    <!--Search form-->
    <form action="<?php echo $this->url(array(), 'bizprofile_enterprise_search')?>" method="POST" id="searchForm">
        <div style="background:#EFEDED none repeat;">
            <div style="padding:10px;">
                <input value="<?php echo isset($this->exp['keyword'])?$this->exp['keyword']:null;?>" name="keyword" type="text" style="width:400px; height:15px;padding:3px 0" />
                <input type="submit" value="<?php echo $this->translator('enterprise_btn_search');?>" style="height:24px; padding:0 0 4px" />
                <a href="<?php echo $this->url(array(), 'bizprofile_enterprise_search_advanced')?>"><?php echo $this->translator('enterprise_search_advanced');?></a>
            </div>
        </div>
    </form>
    <!--End search form-->
</div>
<div class="grid_12">
    <div class="col_70l">
        <div class="subcolumns ">
            <div class="caption_box icon_title">
                <span><?php echo $this->translator('enterprise_search_advanced');?></span>
            </div>
            <div>&nbsp;</div>
            <!--Tab-->
            <div class="subcolumns tabs pb10">
                <ul class="tabNavigation">
                    <li><a href="#tab1" id="basic"><?php echo $this->translator('enterprise_search_enterprise')?></a></li>
                    <li><a href="#tab2" id="info"><?php echo $this->translator('enterprise_search_info')?></a></li>
                    <li><a href="#tab3" id="blog"><?php echo $this->translator('enterprise_search_blog')?></a></li>
                </ul>

                <div id="tab1">
                    <div class="col_70l" style="display:table; width:100%;">
                        <!--advanced form-->
                        <form action="<?php echo $this->url(array(),'bizprofile_enterprise_basic_ajax');?>" method="POST" id="frmBasicAdvanced">
                            <div class="t_bizprofile_register grid_8 pb10">
                                <div class="clearfix">
                                    <label><?php echo $this->translator('search_advanced_keyword'); ?>:</label>
                                    <input value="<?php echo isset($this->exp['keyword'])?$this->exp['keyword']:null;?>" type="text" id="keyword" name="keyword" style="height:15px;padding:3px 0;width: 220px" />
                                </div>
                                <div class="clearfix">
                                    <label><?php echo $this->translator('search_advanced_address'); ?>:</label>
                                    <input value="<?php echo isset($this->exp['contact_address'])?$this->exp['contact_address']:null;?>" type="text" id="address" name="address" style="height:15px;padding:3px 0;width: 220px" />
                                </div>
                                <div class="clearfix">
                                    <label><?php echo $this->translator('search_advanced_city'); ?>:</label>
                                    <select style="width:220px; height:23px; padding: 3px 2px;" name="city">
                                        <option value="all"><?php echo $this->translator('search_all_city');?></option>
                                        <?php foreach($this->city as $key=>$c_row):?>
                                        <option <?php if(@$this->exp['registration_city'] == $key):?>selected<?php endif;?> value="<?php echo $key;?>"><?php echo $c_row;?></option>
                                        <?php endforeach;?>
                                    </select>
                                </div>
                                <div class="clearfix">
                                    <label><?php echo $this->translator('search_advanced_professions'); ?>:</label>
                                    <select style="width:220px; height:23px; padding: 3px 2px;" name="professions">
                                        <option value="all"><?php echo $this->translator('search_all_professions');?></option>
                                        <?php foreach($this->professions as $p_row):?>
                                        <option <?php if(@$this->exp['professions_id'] == $p_row->professions_id):?>selected<?php endif;?> value="<?php echo $p_row->professions_id;?>">
                                            <?php echo ($this->lang == 'vi_VN')?$p_row->professions_name:$p_row->professions_name_en;?>
                                        </option>
                                        <?php endforeach;?>
                                    </select>
                                </div>
                                <div class="clearfix">
                                    <label>&nbsp;</label>
                                    <input type="button" id="basic_btn" value="<?php echo $this->translator('enterprise_btn_search');?>"/>
                                    <span id="basicLoading"></span>
                                </div>
                            </div>
                        </form>
                        <!--end advanced form-->
                    </div>
                    <div id="basicOutput" class="col_70l" style="display:table; width:100%;"></div><!--Output-->

                </div>
                <div id="tab2" style="display: block;">
                    <div class="col_70l" style="display:table; width:100%;">
                    <!--advanced form-->
                        <form action="<?php echo $this->url(array(),'bizprofile_enterprise_info_ajax');?>" method="POST" id="frmInfoAdvanced" onkeypress="return event.keyCode!=13">
                            <div class="t_bizprofile_register grid_8 pb10">
                                <div class="clearfix">
                                    <label><?php echo $this->translator('search_advanced_keyword'); ?>:</label>
                                    <input value="<?php echo isset($this->exp['keyword'])?$this->exp['keyword']:null;?>" type="text" id="keyword" name="keyword" style="height:15px;padding:3px 0;width: 220px" />
                                </div>
                                <div class="clearfix">
                                    <label>&nbsp;</label>
                                    <input type="button" id="info_btn" value="<?php echo $this->translator('enterprise_btn_search');?>"/>
                                    <span id="infoLoading"></span>
                                </div>
                            </div>
                        </form>
                        <!--end advanced form-->
                    </div>
                    <div id="infoOutput" class="col_70l" style="display:table; width:100%;"></div><!--Output-->
                </div>
                <div id="tab3" style="display: block;">
                    <div class="col_70l" style="display:table; width:100%;">
                    <!--advanced form-->
                        <form action="<?php echo $this->url(array(),'bizprofile_enterprise_blog_ajax');?>" method="POST" id="frmBlogAdvanced">
                            <div class="t_bizprofile_register grid_8 pb10">
                                <div class="clearfix">
                                    <label><?php echo $this->translator('search_advanced_keyword'); ?>:</label>
                                    <input value="<?php echo isset($this->exp['keyword'])?$this->exp['keyword']:null;?>" type="text" id="keyword" name="keyword" style="height:15px;padding:3px 0;width: 240px" />
                                </div>
                                <div class="clearfix">
                                    <label><?php echo $this->translator('search_advanced_date'); ?>:</label>
                                    <input value="" type="text" id="from_date" name="from_date" style="height:15px; padding:3px 0; width:100px" />
                                    <label style="width:auto;padding-right:5px;padding-left:15px"><?php echo $this->translator('search_advanced_date_to'); ?></label><input value="" type="text" id="to_date" name="to_date" style="height:15px; padding:3px 0; width:100px" />
                                </div>
                                <div class="clearfix">
                                    <label>&nbsp;</label>
                                    <input type="button" id="blog_btn" value="<?php echo $this->translator('enterprise_btn_search');?>"/>
                                    <span id="blogLoading"></span>
                                </div>
                            </div>
                        </form>
                        <!--end advanced form-->
                    </div>
                    <div id="blogOutput" class="col_70l" style="display:table; width:100%;"></div><!--Output-->
                </div>
            </div>
            <!--end tab-->
        </div>
    </div>
    <div class="col_30r">
        <!--Most viewed box-->
        <?php echo $this->widget('bizprofile','mostviewed',array()); ?>

        <!--Most buy box-->
        <?php echo $this->widget('bizprofile','mostbuy',array()); ?>
    </div>
</div>

<script type="text/javascript" src="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.form/jquery.form.js"></script>

<script type="text/javascript" charset="utf-8">
    $(function () {
        var tabContainers = $('div.tabs > div');
        tabContainers.hide().filter(':first').show();

        $('div.tabs ul.tabNavigation a').click(function () {
                tabContainers.hide();
                tabContainers.filter(this.hash).show();
                $('div.tabs ul.tabNavigation a').removeClass('selected');
                $(this).addClass('selected');
                return false;
        }).filter(':first').click();
    });
</script>
<script type="text/javascript">
$(document).ready(function() {

    /**
    * Create datepicker instances
    */
    $('#from_date').datepicker({ dateFormat: 'dd/mm/yy' });
    $('#to_date').datepicker({ dateFormat: 'dd/mm/yy' });

    /**
    * Ajax submit form basic option
    */
    var basicOptions = {
        target: '#basicOutput', // target element(s) to be updated with server response
        beforeSubmit:  showRequest,
        url: '<?php echo $this->url(array(), 'bizprofile_enterprise_basic_ajax');?>',
        data: { type:'advance' },
        type: 'POST',  // pre-submit callback,
        success: function(){
            $("#basicLoading").html('').removeClass('t_a_ui_helper_loading');
        }
    };
    $('#basic_btn').click(function(){
        $("#basicLoading").html('').addClass('t_a_ui_helper_loading');
        $("#frmBasicAdvanced").ajaxSubmit(basicOptions);
    });

    /**
    * Ajax submit form info option
    */
    var infoOptions = {
        target: '#infoOutput', // target element(s) to be updated with server response
        beforeSubmit:  showRequest,
        url: '<?php echo $this->url(array(), 'bizprofile_enterprise_info_ajax');?>',
        data: { type:'advance' },
        type: 'POST',  // pre-submit callback,
        success: function(){
            $("#infoLoading").html('').removeClass('t_a_ui_helper_loading');
        }
    };
    $('#info_btn').click(function(){
        $("#infoLoading").html('').addClass('t_a_ui_helper_loading');
        $("#frmInfoAdvanced").ajaxSubmit(infoOptions);
    });

    /**
    * Ajax submit form blog option
    */
    var blogOptions = {
        target: '#blogOutput', // target element(s) to be updated with server response
        beforeSubmit:  showRequest,
        url: '<?php echo $this->url(array(), 'bizprofile_enterprise_blog_ajax');?>',
        data: { type:'advance' },
        type: 'POST',  // pre-submit callback,
        success: function(){
            $("#blogLoading").html('').removeClass('t_a_ui_helper_loading');
        }
    };
    $('#blog_btn').click(function(){
        $("#blogLoading").html('').addClass('t_a_ui_helper_loading');
        $("#frmBlogAdvanced").ajaxSubmit(blogOptions);
    });

});
function showRequest(formData, jqForm, options) {
    var queryString = $.param(formData);
    return true;
}
</script>